Skip to content

Update THV-0057 key format to prevent cross-type collisions#69

Merged
jerm-dro merged 1 commit intomainfrom
jerm-dro/thv-0057-key-format-fix
Apr 10, 2026
Merged

Update THV-0057 key format to prevent cross-type collisions#69
jerm-dro merged 1 commit intomainfrom
jerm-dro/thv-0057-key-format-fix

Conversation

@jerm-dro
Copy link
Copy Markdown
Contributor

@jerm-dro jerm-dro commented Apr 9, 2026

Summary

The implementation of per-user rate limiting (stacklok/toolhive#4692) revealed that the RFC's Redis key format for per-user per-operation keys could produce collisions when a userId contains delimiter characters like :tool:.

  • Update per-user per-operation key format to use distinct prefixes (user-tool:, user-prompt:, user-resource:) instead of nesting under user:{userId}:tool:...
  • Place the operation name before the userId so the variable-length userId is always the terminal key component
  • Add explanatory note about why the format uses distinct prefixes

The original format user:{userId}:tool:{toolName} collides with server-level user:{userId} when a userId literally contains :tool:{toolName}. While unlikely in practice (JWT sub claims are typically UUIDs or emails), the distinct prefix approach eliminates the structural ambiguity entirely.

Generated with Claude Code

Per-user per-operation Redis keys now use distinct prefixes
(user-tool:, user-prompt:, user-resource:) instead of nesting
under user:{userId}:tool:... to prevent key collisions when a
userId contains delimiter characters like ":tool:".

The operation name precedes the userId so that the variable-length
userId is always the terminal key component.

Matches the implementation shipped in stacklok/toolhive#4692.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jerm-dro jerm-dro requested a review from JAORMX April 9, 2026 17:39
@jerm-dro jerm-dro merged commit 0b8e5d4 into main Apr 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants